import Fluent
import Vapor


// 更新用户信息的DTO
struct UpdateUserDTO: Content {
    var userId: StringCodable?
    var name: String?
    var age: Int?
    var phone: String?
}

// 返回用户信息的DTO
struct UserDTO: Content {
    var id: UUID?
    var name: String?
    var age: Int?
    var phone: String? 
    
    func toModel() -> User {
        let model = User()
        model.id = self.id
        if let name = self.name {
            model.name = name
        }
        if let age = self.age {
            model.age = age
        }
        if let phone = self.phone {
            model.phone = phone
        }
        return model
    }
}
 
